<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>组件:传递数据</title>
      <script src="https://cdn.bootcss.com/vue/2.4.4/vue.js"></script>

</head>
<body>
  <h3>为组件传递数据,制作可接受参数的组件</h3>
  <div id="myApp">
    <p>你的成绩平均</p>
    <test-result :score="58"></test-result>
    <test-result :score="61"></test-result>
    <test-result :score="90"></test-result>
    <test-result :score="100"></test-result>
  </div>
  <script>
    Vue.component('test-result',{
      props:['score'],
      template:'<div><strong>{{score}}分,{{testResult}}</strong></div>',
      computed:{
        testResult:function(){
          var strResult = "";
          if(this.score<60){
            strResult = '不及格';
          }else if(this.score<90){
            strResult = '中等生';
          }else if(this.score<=100){
            strResult = '优秀生';
          }
          return strResult;
        }
      }
    })
    var myApp = new Vue({
      el:'#myApp'
    })
  </script>
</body>
</html>